package com.marquis.cloud.pagequery;

import java.util.List;

/**
 * Created by tyq on 18/9/17.
 */
public class PaginationGrid<T> {

    private int page;//当前页码
    private int pageSize;//每页显示条数
    private Integer offset;//起始记录
    private Integer endset;//结束记录
    private Long total;//总记录数
    private List<T> rows;//数据集

    public PaginationGrid(){

    }

    public PaginationGrid(int page, int pageSize){
        this.page = page;
        this.pageSize = pageSize;
        if(page == 1){
            this.offset = 1;
            this.endset = pageSize;
        }else {
            this.offset = (page-1) * pageSize + 1;
            this.endset = page * pageSize;
        }
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getOffset() {
        return offset;
    }

    public void setOffset(Integer offset) {
        this.offset = offset;
    }

    public Integer getEndset() {
        return endset;
    }

    public void setEndset(Integer endset) {
        this.endset = endset;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }
}
